package bit2;

public class bitMain16 {
    private static final long count=10_0000_0000L;
    public static void serial(){
        long beg=System.currentTimeMillis();
        int a=0;
        for (long i = 0; i < count; i++) {
            a++;
        }
        int b=0;
        for (long i = 0; i < count; i++) {
            b++;
        }
        long end=System.currentTimeMillis();

        System.out.println(end-beg);
    }
    public static void concurrency(){
        long beg=System.currentTimeMillis();
        Thread t1=new Thread(){
            public void run(){
                int a=0;
                for (long i = 0; i < count; i++) {
                    a++;
                }
            }
        };
        t1.start();
        Thread t2=new Thread(){
            public void run(){
                int b=0;
                for (long i = 0; i < count; i++) {
                    b++;
                }
            }
        };
        t2.start();
        try{
            t1.join();
            t2.join();
        }catch (InterruptedException e) {
            e.printStackTrace();
        }
        long end=System.currentTimeMillis();
        System.out.println(end-beg);
    }
    public static void main(String[] args) {
        concurrency();
    }
}
